<%@ page import="java.sql.ResultSet" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户列表</title>
    <style>
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        tr:hover {
            background-color: #f5f5f5;
        }
        .btn {
            padding: 5px 10px;
            text-decoration: none;
            border-radius: 3px;
        }
        .btn-delete {
            background-color: #f44336;
            color: white;
        }
        .btn-edit {
            background-color: #4CAF50;
            color: white;
        }
    </style>
</head>
<body>
<h1>用户列表</h1>
<a href="addUser.jsp">添加用户</a>

<table>
    <tr>
        <th>userNo</th>
        <th>userName</th>
        <th>userPwd</th>
        <th>birthday</th>
        <th>操作</th>
    </tr>

    <%
        ResultSet rs = (ResultSet) request.getAttribute("users");
        if (rs != null) {
            while (rs.next()) {
    %>
    <tr>
        <td><%= rs.getString("userNo") %></td>
        <td><%= rs.getString("userName") %></td>
        <td><%= rs.getString("userPwd") %></td>
        <td><%= rs.getString("birthday") %></td>
        <td>
            <a href="manageuserServlet?action=delete&id=<%= rs.getString("userNo") %>" class="btn btn-delete">删除</a>
            <a href="editUser.jsp?id=<%= rs.getString("userNo") %>" class="btn btn-edit">编辑</a>
        </td>
    </tr>
    <%
        }
    } else {
    %>
    <tr>
        <td colspan="5">没有找到用户数据</td>
    </tr>
    <%
        }
    %>
</table>
</body>
</html>